package com.web.hr.controller;

import com.web.hr.beans.JSONResult;
import com.web.hr.cymodel.UserTable;
import com.web.hr.service.MainService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


@SuppressWarnings("SpringAutowiredFieldsWarningInspection")
@Controller
@RequestMapping(value = "/main", method = RequestMethod.POST)
public class MainController {
    Logger logger = Logger.getLogger(MainController.class);
    @Autowired
    private MainService mainService;

    @RequestMapping(value = "demo1", method = RequestMethod.POST)
    @ResponseBody
    public JSONResult getUserID() {
        return new JSONResult(0, "Success", mainService.selectDBAccessToken("c3c57c8c67d94d59878c8e7f36c96999"));
    }

    @RequestMapping(value = "demo2", method = RequestMethod.POST)
    @ResponseBody
    public JSONResult getCyUser() {
        //return new JSONResult(0, "Success", mainService.addUserRecord(new UserTable(2, "Test")));
        return new JSONResult(0, "Success", mainService.getUserRecord(1));
    }
}
